/*
 * Flashbox4SettingContainer.h
 *
 *  Created on: 2009-1-20
 *      Author: hequn
 */

#ifndef FLASHBOX4SETTINGCONTAINER_H_
#define FLASHBOX4SETTINGCONTAINER_H_


#include <coecntrl.h>
#include <coecobs.h>
#include <S32FILE.H>
#include "FbSoftKeyBar.h"
#include "FbList.h"
#include "XmlHandler.h"
#include "MulImage.h"


//#define TEST_ZIPFILE



class CFlashbox4SettingContainer : public CCoeControl,//, public MCoeControlObserver
									MSoftKeyObserver,
									MXmlHandlerObserver,
									MListObserver,MMulImageObserver
{
public:
	~CFlashbox4SettingContainer( );
	/**
	 * EPOC default constructor.
	 * @param aRect Frame rectangle for container.
	 */
	void ConstructL(const TRect& aRect , TUid aLastViewID, TInt aActiveTabIndex = 0);
	
protected:
		
	/*
	 * Inherit from MSoftKeyObserver in (FbSoftKeyBar.h)
	 */
	void SoftKeyEvent (TInt aKeyId );
	
private: // Functions from base classes

	/**
	* From CoeControl,SizeChanged.
	*/
	void SizeChanged();

	/**
	* From CoeControl,CountComponentControls.
	*/
	TInt CountComponentControls() const;

	/**
	* From CCoeControl,ComponentControl.
	*/
	CCoeControl* ComponentControl(TInt aIndex) const;

	/**
	* From CCoeControl,Draw.
	*/
	void Draw(const TRect& aRect) const;

	/**
	* From MCoeControlObserver
	* Acts upon changes in the hosted control's state. 
	*
	* @param	aControl	The control changing its state
	* @param	aEventType	The type of control event 
	*/	//For reserve	<update 2009'1.21>
//	void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
	
	/*
	 * Add this function for handle Key pressed and released event.
	 */
	TKeyResponse OfferKeyEventL(const TKeyEvent &aKeyEvent, TEventCode aType);


private:
	//保存设置
	void SaveConfigL();
		
	//Add function 'InitializeControl()' for initializing the control's data
	void InitializeControl();
	
	//from MXmlHandlerObserver
	void OnXmlNodeParseCompletedL (TInt aError, CXmlNode *pXmlNode, TInt aSession);
	//from MListObserver
	/**
		 * pHandle 发出消息的对象
		 * aItemIndex:激活的item 序号
		 * aItemID : 激活的item id
		 * aEventType:事件类型
		 */
	void ListItemEvent (CFbList *pHandle, TInt aItemIndex, TInt aItemID, TInt aEventType );
	
	//confirm your selected file!
	void UpdateSelectedFile(CFbList* pHandle,TInt aItemIndex);
	
	void UpdateFileIcon(const TDesC &aIconPath);
	
	//
	void MulImageReady (CMulImage *pImage );

public:
	//Data
	enum ETextResource
	{
		ETextTitleR = 0,
		ETextItemsR,
		ETextSwitchR
	};
	
	enum EItemsSwitch
	{
		EItemsOff = 0,
		EItemsOn
	};
	
	enum ELoadBmpSource
	{
		ECategorySelBar = 0,
		ECategoryUnSelBar,
		ETurnOffSelBar,
		ETurnOffUnSelBar,
		ETurnOnSelBar,
		ETurnOnUnSelBar,
		EProductSelBar,
		EProductUnSelBar
	};
	
private:
	//For load text resource!
	void LoadTextResourceL(ETextResource aRID);
		
	//Load Bmp Of Content Source!
	void LoadContentBmpResourceL(const TInt &aSourceId);//ELoadBmpSource aSourceId);
	
	
	//Data
	CFbsBitmap *m_pAppLogoBmp;
	
	CFbsBitmap *m_pCategoryBarSelBmp;	
	CFbsBitmap *m_pTurnOnOrOffSelBmp;
	
	CMulImage *m_pFileImage;
	
	//Tab Image
	CFbsBitmap *m_pTabImgArray[2];
	CFbsBitmap *m_pTabImgMaskArray[2];
	
	TInt iSetItembackFocus;
	TInt8 iItemsSetValue; //is state on
	
	
	HBufC* buf_SettingTitle;  //view title
	HBufC* buf_SettingDescript; //state descript
	HBufC* buf_SettingSubTitle[2]; //tab's title
	HBufC* buf_SettingItemSwitch; //state value
	HBufC*	m_pFileSelectTitle[2];
	
	//Handle SoftKeyBar!
	CFbSoftKeyBar *m_pSoftKeyBar;
	
	//Record the MainView Tab Index
	TInt iActiveMainIndex;
	//Record Last ViewID
	TInt32 iLastViewID;
	
	//
	TInt iCurrentTabId;
	
	//待选文件列表
	CFbList			*m_pFileList;
	CXmlHandler		*m_pXmlHandler;	//xml解析器	
	
};


#endif /* FLASHBOX4SETTINGCONTAINER_H_ */
